package com.chun.api;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class ApiGateWayServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	ApplicationContext context;
	private ApiGateWayHand apiHand;
	@Override
	public void init() throws ServletException {
		// TODO Auto-generated method stub
		super.init();
		context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
		apiHand = context.getBean(ApiGateWayHand.class);
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		 
		apiHand.handle(req,resp);
	}
	
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		apiHand.handle(req,resp);
	}
	
	

}
